import { Items, ResPage } from "@/api/interface/index";
import httpss from "@/api/http";

//获取商品数据
export const ItemShops = (parmas: Items.Shops) => {
  console.log("shujss", parmas);
  return httpss.post<ResPage<Items.Shops>>(`/item/page`, parmas);
};
//新增商品
export const ItemsPost = (parmas: Items.Shops) => {
  console.log("提交数据", parmas);
  return httpss.post(`/item//save`, parmas);
};
//修改/更新商品
export const ItemsPut = (parmas: Items.Shops) => {
  console.log("修改数据", parmas);
  return httpss.put(`/item/update`, parmas);
};

//删除商品
export const deleteItemId = (params: { id: number }) => {
  console.log("删除商品Id数据", params);
  return httpss.delete(`/item/delete`, { params });
};
//批量删除
export const deleteItemIds = (params: { id: number[] }) => {
  console.log("删除批量数据商品", params);
  return httpss.post(`/item/deletes`, params);
};

//导入下载模板
export const ItemIemplate = () => {
  console.log("模板下载成功");
  return httpss.get(`/item/template`, { responseType: "blob" });
};

//导入商品数据excel
export const ItemImport = (parmas: Items.Shops) => {
  console.log("导入excel商品数据", parmas);
  return httpss.post(`/item/import`, parmas, {
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
};
//导出商品数据excel
export const ItemExport = () => {
  console.log("导出商品数据");
  return httpss.get(`/item/export`, { responseType: "blob" });
};
